
<cffunction name="getTag">
<cfargument name="fname">
<cfargument name="fpath">

<cfset tags=structnew()>
<cfquery  datasource="101tf2" name="getAI">
			select * from  scanTagsAI 
</cfquery>
<cfloop   query="getAI">

		
<cftry>
<cfloop list='#str#' index='i'>

	<cfif  op eq 'findinname'>
		<cfif findnocase( i,fname)>
			<cfset tags[tag] = tag>
			
		</cfif>	
	</cfif>
	<cfif  op eq 'findinall'>
		<cfif findnocase(i,fname)>
			<cfset tags[tag]=tag>
		</cfif>	
		<cfif findnocase(i,fpath)>
			<cfset tags[tag]=tag>
		</cfif>
	</cfif>
	<cfif op eq 'findindir'>
		<cfif findnocase(i,fpath)>
			<cfset tags[tag]=tag>
		</cfif>	
	</cfif> 
</cfloop>	
<cfcatch >
error<br>
</cfcatch>
</cftry>
</cfloop>	
<cfreturn tags>
</cffunction>
 
<cfquery  datasource="101tf2" name="allFiles">

select * from scan 
</cfquery>
<!--- <div id="progressContainer"  >
    <div id="progressBar"  >
    	<div id="per"  > </div>
        <div id="txt"  > </div>
     </div>
</div> --->
<cfflush>
<cfset lastProg=-1>

<cfloop   query="allFiles">
<cfprocessingdirective suppressWhiteSpace="true">
<cfset prog=(currentrow*100) / recordcount >
<cfif lastProg neq #Round(prog)#>
<script>
	top.document.getElementById("progressBar").style.width='<cfoutput>#Round(prog)*progressWidth#</cfoutput>px';
	top.document.getElementById("per").innerHTML='<cfoutput>#Round(prog)#% #currentrow# of #recordcount#</cfoutput>';
</script>
</cfif>
<cfflush interval="1">
<cftry>
<cfset fileTag=getTag(name,dir)>
		<cfloop collection="#fileTag#" item="i">
			 <cfquery  datasource="101tf2" name="allFiles">
				insert into scanTags (id,tag) values('#id#','#i#')
			</cfquery>  
 		<cfif lastProg neq #Round(prog)#><script>top.document.getElementById("txt").innerHTML='<cfoutput> matching - #name# #i#</cfoutput>';</script></cfif>
		</cfloop>
<cfcatch><cfif lastProg neq #Round(prog)#><script>top.document.getElementById("txt").innerHTML='<cfoutput>    #name# already tagged.</cfoutput>';</script></cfif></cfcatch>
</cftry>  
<cfflush interval=1>
<cfset lastProg=#Round(prog)#> </cfprocessingdirective>
</cfloop>

	 